<?php
require_once("includes/prepend.php");
require_once("includes/lifesubnav.php");
$blodKinds = $page->blogKinds;
$blog = $page->blog;
if (!empty($blog)){
	$blogId =$blog[0]["id"];
	$blogTitle =$blog[0]["title"];
	$blogKind =$blog[0]["kind"];
	$blogContent =$blog[0]["content"];
	$blogQuanxian =$blog[0]["quanxian"];
}
$editor =$page->editor;
?>
<script type="text/javascript" src="js/blog.js"></script>
<script type="text/javascript">
if(blogDraft){
	clearInterval(blogDraft);
}
//every 2 minutes save blog draft
var blogDraft = setInterval("addBlogDraft()",120000);
//addBlogDraft();
</script>
<div id="maincontent"><!--start maincontent-->
<form action="blog.php" method="POST" enctype="multipart/form-data" class="blogform">
<div class="blogheadtitlenew">发表文章</div>
<input type="hidden" value="<?php echo $editor;?>" name="postType" id="postType" />
<input type="hidden" value="<?php echo $blogId;?>" name="blogId" id="blogId" />
<input type="hidden" value="" name="blogDraftId" id="blogDraftId" />
<div class="myblogtitlediv">标题：<input type="text" name="title" class="myblogtitle" id="myblogtitle" value="<?php echo $blogTitle;?>" /></div>
<div id="blogdraftbox">读取草稿（<span id="blogdraftnum"><?php echo $page->draftId;?></span>）</div>
<div class="myblogtitlediv">分类：
	<select name="kind" class="myBlogKind" id="blogKindSelect">
	<?php 
		foreach ($blodKinds as $key=>$values){
			$kind = $values[0];
			$kindId = $values[1];
			if($blogKind==$kindId){
				echo "<option value='$kindId' selected>$kind</option>";
			}
			echo "<option value='$kindId'>$kind</option>";
		}
	?>
		</select>&nbsp;&nbsp;&nbsp;<a onclick="addBlogKind(this)" class="blognewfeilei">添加分类</a>
</div>
<div class="myblogmaintext">
<?php
// Include CKEditor class.
include("js/ckeditor/ckeditor.php");
require_once 'js/ckfinder/ckfinder.php' ;
$initialValue = '<p>Just click the <b>Image</b> or <b>Link</b> button, and then <b>&quot;Browse Server&quot;</b>.</p>' ;

$CKEditor = new CKEditor();
CKFinder::SetupCKEditor( $CKEditor, 'js/ckfinder/' ) ;
$CKEditor->returnOutput = true;
$CKEditor->basePath = 'js/ckeditor/';

$CKEditor->config['width'] = 973;
$CKEditor->config['height'] = 500;
$CKEditor->config['uiColor'] = '#434343';
$CKEditor->config['font_names']='宋体;黑体;隶书;楷体_GB2312;华文行楷;Arial;Comic Sans MS;Courier New;Tahoma;Times New Roman;Verdana';
// Configuration that will be used only by the second editor.
$config['toolbar'] = array(
	array('Font','FontSize'/*,'Format','Styles'*/),
	array('TextColor','BGColor','Bold','Italic','Underline','Strike','Subscript','Superscript'),
	array('Image','Flash','Smiley','SpecialChar','Link','Unlink','Table','HorizontalRule'),
	array('JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock','NumberedList','BulletedList','Outdent','Indent')/*,
	array('Source','Undo','Redo')*/
	/*array('UIColor')*/
);
//$config['skin'] = 'v2';
$CKEditor->textareaAttributes = array("cols" => 95, "rows" =>50);
$initialValue = $blogContent;
$code = $CKEditor->editor("editor1", $initialValue,$config);
echo $code;
?>
</div>

<div class="myblogtitlediv">查看权限：&nbsp;&nbsp;
<?php
	switch ($blogQuanxian){
		case 0:$anyOne = "checked";break;
		case 1:$anyFriend = "checked";break;
		case 2:$onlyMyself = "checked";break;
		default:return false;
	
	}

?>
<input type="radio" name="quanxian" value="0" class="" <?php echo $anyOne; ?>>任何人<input type="radio" name="quanxian" value="1" class="blogquanxianr" <?php echo $anyFriend; ?>>仅好友<input type="radio" name="quanxian" value="2" class="blogquanxianr" <?php echo $onlyMyself; ?> />仅自己

</div>
<div class="myblogsubmitdiv">
	<input type="button" value="发表文章" class="blogButton"  id="submmitBlogButton" /> <input type="button" value="保存草稿" class="blogButton" id="setBlogDraft" />
</div>

</form>
</div><!--end maincontent--->

<?php require_once("includes/pagefoot.php");
?>